package cn.itsource.aigou.client;

import cn.itsource.aigou.domain.ProductDoc;
import cn.itsource.aigou.util.AjaxResult;
import cn.itsource.aigou.util.PageList;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@FeignClient(value = "COMMON-SERVICE")
@Component
public interface ProductESClient {

    /**
     * 保存一条数据
     * @param productDoc
     * @return
     */
    @PostMapping("/es/save")
    public AjaxResult save(@RequestBody ProductDoc productDoc);

    /**
     * 批量保存
     * @param productDocs
     * @return
     */
    @PostMapping("/es/saveBatch")
    public AjaxResult save(@RequestBody List<ProductDoc> productDocs);

    /**
     * 删除
     * @param productId
     * @return
     */
    @DeleteMapping("/es/delete")
    public AjaxResult delete(@RequestParam("productId") Long productId);

    /**
     * 批量删除
     * @param productDocs
     * @return
     */
    @DeleteMapping("/es/deleteBatch")
    public AjaxResult delete(@RequestBody List<ProductDoc> productDocs);

    /**
     * 高级查询
     * @param param
     * @return
     */
    @PostMapping("/es/search")
    PageList<ProductDoc> search(@RequestBody Map<String,Object> param);
}
